package shape;

import java.awt.Color;
import java.awt.Graphics;

import net.jcip.annotations.Immutable;

@Immutable
public class ShapeColourDecorator extends AbstractShapeDecorator {

	private final Color colour;

	public ShapeColourDecorator(final Shape decoratedShape, final Color colour) {
		super(decoratedShape);
		this.colour = colour;
	}

	@Override
	public void draw() {
		decoratedShape.draw();
		setColour();
	}

	private void setColour() {
		System.out.println("Shape is coloured: " + colour);
	}

	@Override
	public void paintShape(Graphics g) {
		decoratedShape.paintShape(g);
		g.setColor(colour);
		fillShape(g);
	}
	
	@Override
	public void fillShape(Graphics g) {
		decoratedShape.fillShape(g);
	}

	@Override
	public int getX() {
		return decoratedShape.getX();
	}

	@Override
	public int getY() {
		return decoratedShape.getY();
	}

	@Override
	public int getSize() {
		return decoratedShape.getSize();
	}
	
	public static Shape decorate(Shape shape, Color colour) {
		return new ShapeColourDecorator(shape, colour);
	}
}
